class Solution {
    public int[] twoSum(int[] nums, int target) {
        int[]result = new int[2];
        int temp = nums[0];
        int compare = target - temp;
        int i = 0;
        int j = 0;

        for (i = 1; i < nums.length; i++) {
            if (compare == nums[i]) {
                result[0] = i;
                result[1] = j;
                return result;
            }
        }

        for (i = 0; i < nums.length; i++) {
            if (nums[i] != nums[0]) {
                compare = target - nums[i];

                for (j = i + 1; j < nums.length; j++) {
                    if (compare == nums[j]) {
                        result[0] = i;
                        result[1] = j;
                        return result;
                    }
                    else if (nums[j] == nums[i]) nums[j] = nums[0];
                }
            }
            else {
                continue;
            }
        }
        return result;
    }
}